import { createApp } from 'vue'

import Cookies from 'js-cookie'

import ElementPlus from 'element-plus'
import locale from 'element-plus/lib/locale/lang/zh-cn' // 中文语言

import '@/assets/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive

// 注册指令
import plugins from './plugins' // plugins
import { download } from '@/utils/request'

// svg图标
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon'
import elementIcons from '@/components/SvgIcon/svgicon'

import './permission' // permission control

import { useDict } from '@/utils/dict'
import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'

// 分页组件
import Pagination from '@/components/Pagination'
// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar'
// 富文本组件
import Editor from "@/components/Editor"
// 文件上传组件
import FileUpload from "@/components/FileUpload"
import FilesUpload from "@/components/FilesUpload"
// 图片上传组件
import ImageUpload from "@/components/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/ImagePreview"
    // 自定义树选择组件
    ;
import DictTag from '@/components/DictTag';
import DictUpload from '@/components/DictUpload';
import TreeSelect from '@/components/TreeSelect';
// 字典标签组件
import CustomTable from '@/components/customTable/index';

const app = createApp(App)

// 全局方法挂载
app.config.globalProperties.useDict = useDict
app.config.globalProperties.download = download
app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels
app.config.globalProperties.getProvinces = () => {
    let province = [
        { "ProID": -1, "name": " 全国", "ProSort": 1, "ProRemark": "全国" },
        { "ProID": 1, "name": "北京", "ProSort": 1, "ProRemark": "直辖市" }, { "ProID": 2, "name": "天津", "ProSort": 2, "ProRemark": "直辖市" }, { "ProID": 3, "name": "河北", "ProSort": 5, "ProRemark": "省份" }, { "ProID": 4, "name": "山西", "ProSort": 6, "ProRemark": "省份" }, { "ProID": 5, "name": "内蒙古", "ProSort": 32, "ProRemark": "" }, { "ProID": 6, "name": "辽宁", "ProSort": 8, "ProRemark": "省份" }, { "ProID": 7, "name": "吉林", "ProSort": 9, "ProRemark": "省份" }, { "ProID": 8, "name": "黑龙江", "ProSort": 10, "ProRemark": "省份" }, { "ProID": 9, "name": "上海", "ProSort": 3, "ProRemark": "直辖市" }, { "ProID": 10, "name": "江苏", "ProSort": 11, "ProRemark": "省份" }, { "ProID": 11, "name": "浙江", "ProSort": 12, "ProRemark": "省份" }, { "ProID": 12, "name": "安徽", "ProSort": 13, "ProRemark": "省份" }, { "ProID": 13, "name": "福建", "ProSort": 14, "ProRemark": "省份" }, { "ProID": 14, "name": "江西", "ProSort": 15, "ProRemark": "省份" }, { "ProID": 15, "name": "山东", "ProSort": 16, "ProRemark": "省份" }, { "ProID": 16, "name": "河南", "ProSort": 17, "ProRemark": "省份" }, { "ProID": 17, "name": "湖北", "ProSort": 18, "ProRemark": "省份" }, { "ProID": 18, "name": "湖南", "ProSort": 19, "ProRemark": "省份" }, { "ProID": 19, "name": "广东", "ProSort": 20, "ProRemark": "省份" }, { "ProID": 20, "name": "海南", "ProSort": 24, "ProRemark": "省份" }, { "ProID": 21, "name": "广西", "ProSort": 28, "ProRemark": "" }, { "ProID": 22, "name": "甘肃", "ProSort": 21, "ProRemark": "省份" }, { "ProID": 23, "name": "陕西", "ProSort": 27, "ProRemark": "省份" }, { "ProID": 24, "name": "新疆", "ProSort": 31, "ProRemark": "" }, { "ProID": 25, "name": "青海", "ProSort": 26, "ProRemark": "省份" }, { "ProID": 26, "name": "宁夏", "ProSort": 30, "ProRemark": "" }, { "ProID": 27, "name": "重庆", "ProSort": 4, "ProRemark": "直辖市" }, { "ProID": 28, "name": "四川", "ProSort": 22, "ProRemark": "省份" }, { "ProID": 29, "name": "贵州", "ProSort": 23, "ProRemark": "省份" }, { "ProID": 30, "name": "云南", "ProSort": 25, "ProRemark": "省份" }, { "ProID": 31, "name": "西藏", "ProSort": 29, "ProRemark": "" }, { "ProID": 32, "name": "台湾", "ProSort": 7, "ProRemark": "省份" }, { "ProID": 33, "name": "澳门", "ProSort": 33, "ProRemark": "特别行政区" }, { "ProID": 34, "name": "香港", "ProSort": 34, "ProRemark": "特别行政区" }
    ]
    return province
}

// 全局组件挂载
app.component('DictTag', DictTag)
app.component('Pagination', Pagination)
app.component('TreeSelect', TreeSelect)
app.component('FileUpload', FileUpload)
app.component('FilesUpload', FilesUpload)
app.component('ImageUpload', ImageUpload)
app.component('ImagePreview', ImagePreview)
app.component('RightToolbar', RightToolbar)
app.component('Editor', Editor)
app.component('CustomTable', CustomTable);
app.component('DictUpload', DictUpload);
;

app.use(router)
app.use(store)
app.use(plugins)
app.use(elementIcons)
app.component('svg-icon', SvgIcon)

directive(app)

// 使用element-plus 并且设置全局的大小
app.use(ElementPlus, {
    locale: locale,
    // 支持 large、default、small
    size: Cookies.get('size') || 'default'
})

app.mount('#app')
